package com.xtoad.ecms.common.web.base;

import javax.persistence.Column;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.MappedSuperclass;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import java.io.Serializable;
import java.util.Date;

import static javax.persistence.GenerationType.IDENTITY;


/**
 * 基础实体类
 *
 * @author xtoad
 * @date 2020/05/29
 */
@MappedSuperclass
public class BaseModel implements Serializable {

    /**
     * ID
     */
    @Id
    @GeneratedValue(strategy = IDENTITY)
    private Long id;

    /**
     * 记录创建时间
     */
    @Temporal(TemporalType.TIMESTAMP)
    @Column(nullable = false, columnDefinition = "timestamp comment '记录创建时间'")
    private Date createTime;

    /**
     * 记录创建用户
     */
    @Column(nullable = false, columnDefinition = "varchar(100) comment '记录创建人'")
    private String createUser;

    /**
     * 记录最后修改时间
     */
    @Temporal(TemporalType.TIMESTAMP)
    @Column(nullable = false, columnDefinition = "timestamp comment '记录最后修改时间'")
    private Date lastUpdateTime;

    /**
     * 记录最后修改用户
     */
    @Column(nullable = false, columnDefinition = "varchar(100) comment '记录最后修改人'")
    private String lastUpdateUser;


    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    public String getCreateUser() {
        return createUser;
    }

    public void setCreateUser(String createUser) {
        this.createUser = createUser;
    }

    public Date getLastUpdateTime() {
        return lastUpdateTime;
    }

    public void setLastUpdateTime(Date lastUpdateTime) {
        this.lastUpdateTime = lastUpdateTime;
    }

    public String getLastUpdateUser() {
        return lastUpdateUser;
    }

    public void setLastUpdateUser(String lastUpdateUser) {
        this.lastUpdateUser = lastUpdateUser;
    }

    @Override
    public String toString() {
        return "BaseModel{" +
                "id=" + id +
                ", createTime=" + createTime +
                ", createUser='" + createUser + '\'' +
                ", lastUpdateTime=" + lastUpdateTime +
                ", lastUpdateUser='" + lastUpdateUser + '\'' +
                '}';
    }
}
